{extend name="admininfo/admininfo" /}
{block name='main'}


<h2>歌曲列表</h2>


<a class="btn btn-default btn-success add" href="{:url('admin/Musics/addmusic')}">
 添加歌曲
</a>
<table class="table table-hover table-bordered" style="text-align: center;">
    <tr>
        <th style="text-align: center;">
            id
        </th>
        <th style="text-align: center;">
            IMG
        </th>
        <th style="text-align: center;">
            歌曲名
        </th>
        <th style="text-align: center;">
            操作
        </th>
    </tr>

    {foreach $list as $v}
    <tr id='{$v["id"]}'>
        <td>
            {$v['id']}
        </td>
        <td>
             <img src="__UPLOAD__/music-img/{$v.img}" alt="" width="50px">
        </td>
        <td>
            {$v['name']}
        </td>
        <td >
            <div class="row clearfix">
                <!--<div class="col-md-12 column" >-->
                <a href="{:url('admin/Musics/editmusic?id='.$v['id'])}"  class="btn btn-default btn-success">
                    编辑
                <a/>
                <a  class="btn btn-default btn-danger del" data_id='{$v["id"]}'>删除</a>
            </div>
        </td>
    </tr>
    {/foreach}
</table>
<div>
    {$list->render()}
</div>
<script>
    $(function(){
        $('.del').click(function(){
       
            var a = confirm('你确定删除吗!!!!!');
            if (a) {

                var id = $(this).attr('data_id');
                $.ajax({
                    type:'post',
                    url:  'del',
                    data:{ 'id': id },
                    
                    success: function(data){
                        if (data>0) {
                            $('#'+id).remove();
                            alert('删除成功');
                        }else{
                            alert('删除失败');
                        }  
                    },
                    error:function(){
                        alert('ajax执行失败');
                    }

                })
            }
        })
    })

</script>



{/block}